package com.lx.yygh.hosp.controller;

import com.lx.yygh.common.result.Result;
import com.lx.yygh.hosp.service.ScheduleService;
import com.lx.yygh.model.hosp.Schedule;
import com.lx.yygh.vo.hosp.ScheduleOrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import sun.net.sdp.SdpSupport;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author c先生
 * @date 2022年10月18日 下午 4:07:52
 * @describe
 */
@Api(tags = "排班管理")
@RestController
@RequestMapping("/admin/hosp/schedule")
//@CrossOrigin
public class ScheduleController {

    @Resource
    private ScheduleService scheduleService;

    @ApiOperation(value = "排班功能")
    @GetMapping("/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable("page")Long page,
                                  @PathVariable("limit")Long limit,
                                  @PathVariable("hoscode")String hoscode,
                                  @PathVariable("depcode")String depcode){
        Map<String,Object> ruleSchedule = scheduleService.getRuleSchedule(page, limit, hoscode, depcode);
        return Result.ok(ruleSchedule);
    }

    @ApiOperation(value = "查询当前日期的排班详情")
    @GetMapping("/getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable("hoscode")String hoscode,
                                    @PathVariable("depcode")String depcode,
                                    @PathVariable("workDate")String workDate){
        List<Schedule> list = scheduleService.getScheduleDetail(hoscode,depcode,workDate);
        return Result.ok(list);
    }

    @ApiOperation(value = "根据排班id获取预约下单数据")
    @GetMapping("/inner/getScheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleOrderVo(@PathVariable("scheduleId")String scheduleId){
        ScheduleOrderVo scheduleOrderVo = scheduleService.getScheduleOrderVo(scheduleId);
        return scheduleOrderVo;
    }
}
